
CC = gcc
SRC = $(wildcard *.c)
OBJ = $(addprefix $(BUILD_DIR)/,$(notdir $(SRC:.c=.o)))
#OBJ = $(patsubst %.c, %.o, $(SRC))

TRAGET = settings
BUILD_DIR = build

ifeq ($(PRODUCT_A), y)
APPLICATION_FLAGS += \
	-DUSER_PRODUCT_A
endif

ifeq ($(PRODUCT_B), y)
APPLICATION_FLAGS += \
	-DUSER_PRODUCT_B
endif

C_INCLUDES +=  \
	-I../Common/Flash \
	-I../Common/Settings \
	-I../Common

C_FLAG += -Wall -MD -MP -MF"$(@:%.o=%.d)"

C_FLAG += -DUSER_SETTING_IN_HOST
C_FLAG += $(APPLICATION_FLAGS)
 
all: $(BUILD_DIR) $(BUILD_DIR)/$(TRAGET)

$(BUILD_DIR)/$(TRAGET):$(OBJ) Makefile | $(BUILD_DIR) 
	$(CC)  $< -o $@

$(OBJ): $(SRC)  Makefile | $(BUILD_DIR) 
	$(CC) -c $(C_FLAG) $(C_INCLUDES) $< -o $@

$(BUILD_DIR):
	@-mkdir $@

clean:
	@rm -rf $(TRAGET)
	@rm -rf $(OBJ)
	@rm -rf $(BUILD_DIR)

-include $(wildcard $(BUILD_DIR)/*.d)

# *** EOF ***